#include "bldg_ctzn_spawner.h"
#include "../error.h"
#include "../game_engine.h"
#include "../character.h"
#include "../AI/behavior/AIB_idle.h"

#define BLDG_WIDTH  3
#define BLDG_HEIGHT 2

#define BLDG_NTR_X  1
#define BLDG_NTR_Y  1

bldg_ctzn_spawner::bldg_ctzn_spawner(uicoord pos):
building( pos.x, pos.y, BLDG_WIDTH, BLDG_HEIGHT ), lastspawn( clock() ){}
bldg_ctzn_spawner::bldg_ctzn_spawner(unsigned int xpos,unsigned int ypos):
building( xpos, ypos, BLDG_WIDTH, BLDG_HEIGHT ), lastspawn( clock() ){}

void bldg_ctzn_spawner::execAI(clock_t now){
    if( now - lastspawn > 10000 ){
        //game_engine::addChar( new character( pos.x + BLDG_NTR_X, pos.y + BLDG_NTR_Y, new AIB_idle() ) );
        lastspawn = now;
    }
}
void bldg_ctzn_spawner::install(map* mymap){
    building::install(mymap);
    map_elem* el = mymap->elem( pos.x + BLDG_NTR_X, pos.y + BLDG_NTR_Y);
    if( !(el->status & sta_bldg_ntr) ){
        error::log(error::con_only,"Map Update: Entree en (%d,%d)\n", pos.x + BLDG_NTR_X, pos.y + BLDG_NTR_Y);
        el->status |= sta_bldg_ntr;
    }
}

